<?php
/*
+-----------------------------------------------------------------------------+
| $Id: *.php 2009-08-18 08:41:22Z Bleakwind $
| Copyright (c) 2003-2010 Bleakwind (www.weaverdream.com)
| http://www.weaverdream.com/
+-----------------------------------------------------------------------------+
*/

if (!defined( 'ENTRY_INDEX')){
    echo "<h1>Forbidden</h1><p>You don't have permission to access on this server.</p>";
    exit;
}

// member_list
$total_record = func::db_count_record(DB_TABLE_MEMBER, "if_enable='1'");
$bwpage->set_record_listnum($CONFIG['page_record_member_list']);
$bwpage->set_record($total_record);
$bwpage->page($CONFIGURE['common']['control_index']."?act=member_list&pag=%s");
$sql = "SELECT member.*,
            member_detail.mid as mid,
            member_detail.realname as realname,
            member_detail.gender as gender,
            member_detail.birthday as birthday,
            member_detail.address as address,
            member_detail.postalcode as postalcode,
            member_detail.telephone as telephone,
            member_detail.mobile as mobile,
            member_detail.avatar_type as avatar_type,
            member_detail.avatar_value as avatar_value,
            member_detail.website as website,
            member_detail.gtalk as gtalk,
            member_detail.msn as msn,
            member_detail.icq as icq,
            member_detail.qq as qq,
            member_detail.yahoo as yahoo,
            member_detail.bio as bio,
            member_detail.sign as sign,
            member_detail.last_post as last_post,
            member_detail.total_topic as total_topic,
            member_detail.total_reply as total_reply,
            member_detail.total_elite as total_elite,
            member_detail.remark as remark,
            member_group.*
        FROM ".DB_TABLE_MEMBER." member
            LEFT JOIN ".DB_TABLE_MEMBER_DETAIL." member_detail ON member_detail.mid=member.id
            LEFT JOIN ".DB_TABLE_MEMBER_GROUP." member_group ON member_group.mg_type=member.mg_type
                AND (member_group.mg_point_begin<=member.point || member_group.mg_point_begin IS NULL)
                AND (member_group.mg_point_end>=member.point || member_group.mg_point_end IS NULL)
        WHERE member.if_enable='1'
        ORDER BY member.time_created DESC, member.id DESC
        LIMIT ".$bwpage->record_listfirst.",".$bwpage->record_listnum;
$result = &$db->Execute($sql);
if (!$result) {
    echo $db->ErrorMsg();
} else {
    while (!$result->EOF) {
        $member_list[$result->fields['id']] = array(
                'id'                      => $result->fields['id'],
                'username'                => $result->fields['username'],
                'email'                   => $result->fields['email'],
                'card'                    => $result->fields['card'],
                'mg_type'                 => $result->fields['mg_type'],
                'mg_type_expired' => $result->fields['mg_type_expired'],
                'silver'                  => $result->fields['silver'],
                'point'                   => $result->fields['point'],
                'bonus'                   => $result->fields['bonus'],
                'pile1'                   => $result->fields['pile1'],
                'pile2'                   => $result->fields['pile2'],
                'pile3'                   => $result->fields['pile3'],
                'pile4'                   => $result->fields['pile4'],
                'pile5'                   => $result->fields['pile5'],
                'pile6'                   => $result->fields['pile6'],
                'time_created'            => $result->fields['time_created'],
                'time_lastvisit'          => $result->fields['time_lastvisit'],
                'cumulant_silver'         => $result->fields['cumulant_silver'],
                'cumulant_offer'          => $result->fields['cumulant_offer'],
                'cumulant_online'         => $result->fields['cumulant_online'],

                'mg_id'                         => $result->fields['mg_id'],
                'mg_type'                       => $result->fields['mg_type'],
                'mg_point_begin'                => $result->fields['mg_point_begin'],
                'mg_point_end'                  => $result->fields['mg_point_end'],
                'mg_ag_id'                      => $result->fields['mg_ag_id'],
                'mg_name'                       => $result->fields['mg_name'],
                'mg_brief'                      => $result->fields['mg_brief'],
                'mg_icon'                       => $result->fields['mg_icon'],
                'mg_privilege'                  => unserialize($result->fields['mg_privilege']),
                'mg_fileallow'                  => unserialize($result->fields['mg_fileallow']),
                'mg_if_enable'                  => $result->fields['mg_if_enable'],
                'mg_rank'                       => $result->fields['mg_rank'],
        );
        if ($member_list[$result->fields['id']]['mg_type_expired'] > 0) {
            if ($sys->check_member_group($member_list[$result->fields['id']]['id'], $member_list[$result->fields['id']]['mg_type_expired'])) {
                $member_list[$result->fields['id']]['mg_type']                  = $CONFIG['default_group_member'];
                $member_list[$result->fields['id']]['mg_type_expired']  = 0;
                $this_member_group = $sys->return_member_group($member_list[$result->fields['id']]['mg_type'], $member_list[$result->fields['id']]['point'], "*");
                $member_list[$result->fields['id']]['mg_id']                    = $this_member_group['mg_id'];
                $member_list[$result->fields['id']]['mg_type']                  = $this_member_group['mg_type'];
                $member_list[$result->fields['id']]['mg_point_begin']           = $this_member_group['mg_point_begin'];
                $member_list[$result->fields['id']]['mg_point_end']             = $this_member_group['mg_point_end'];
                $member_list[$result->fields['id']]['mg_ag_id']                 = $this_member_group['mg_ag_id'];
                $member_list[$result->fields['id']]['mg_name']                  = $this_member_group['mg_name'];
                $member_list[$result->fields['id']]['mg_brief']                 = $this_member_group['mg_brief'];
                $member_list[$result->fields['id']]['mg_icon']                  = $this_member_group['mg_icon'];
                $member_list[$result->fields['id']]['mg_privilege']             = unserialize($this_member_group['mg_privilege']);
                $member_list[$result->fields['id']]['mg_fileallow']             = unserialize($this_member_group['mg_fileallow']);
                $member_list[$result->fields['id']]['mg_if_enable']             = $this_member_group['mg_if_enable'];
                $member_list[$result->fields['id']]['mg_rank']                  = $this_member_group['mg_rank'];
            }
        }
        $member_list[$result->fields['id']]['detail'] = array(
                'mid'                    => $result->fields['mid'],
                'realname'               => $result->fields['realname'],
                'gender'                 => $result->fields['gender'],
                'birthday'               => $result->fields['birthday'],
                'address'                => $result->fields['address'],
                'postalcode'             => $result->fields['postalcode'],
                'telephone'              => $result->fields['telephone'],
                'mobile'                 => $result->fields['mobile'],
                'avatar_type'            => $result->fields['avatar_type'],
                'avatar_value'           => $result->fields['avatar_value'],
                'website'                => $result->fields['website'],
                'gtalk'                  => $result->fields['gtalk'],
                'msn'                    => $result->fields['msn'],
                'icq'                    => $result->fields['icq'],
                'qq'                     => $result->fields['qq'],
                'yahoo'                  => $result->fields['yahoo'],
                'bio'                    => $result->fields['bio'],
                'sign'                   => $result->fields['sign'],
                'last_post'              => $result->fields['last_post'],
                'total_topic'            => $result->fields['total_topic'],
                'total_reply'            => $result->fields['total_reply'],
                'total_elite'            => $result->fields['total_elite'],
                'remark'                 => $result->fields['remark'],
        );
        $result->MoveNext();
    }
}
$t->assign(array(
    "member_list"   => $member_list,
    "pagination"    => $bwpage->pagination,
));
//////
$public_var['page_place'][] = $LANGUAGE['s']['member_list']['page_place'];
?>
